package com.gpscookie.vocabularystory;

import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.graphics.Color;
import android.util.Log;
import android.view.ViewParent;
import android.widget.LinearLayout;

public class AbstractActivity extends Activity {
    private static final int DIALOG_PROGRESS = 0;
	private boolean isBusy = false;
	private ProgressDialog dialog = null;
	
    @Override
    protected Dialog onCreateDialog(int id) {
    	switch(id) {
		case DIALOG_PROGRESS :
				if (dialog==null) {
		            dialog  = new ProgressDialog(this);	            
		            dialog.setMessage(this.getResources().getText(R.string.loading));
		            dialog.setIndeterminate(true);
		            dialog.setCancelable(true);
				}
	            return dialog;
    	}
    	return null;    	
    }	

    public boolean isBusy() {
    	return isBusy;
    }
    
    public void setBusy(boolean busy) {
		try {
			if (busy) {
				isBusy = true;
				this.showDialog(DIALOG_PROGRESS);			
			} else {
				isBusy = false;
				this.dismissDialog(DIALOG_PROGRESS);			
			}
		} catch (IllegalArgumentException e) {
			Log.d("AbstractActivity.setBusy", e.toString());
		}    	
    }

}
